package com.fita.entity.client;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.springframework.format.annotation.DateTimeFormat;
import com.demo2do.core.utils.DateFormatUtils;
import com.fita.entity.principal.Principal;

/**
 * @description: 客户访谈记录
 * @author: 11200
 * @date: 2019/6/21
 */
@Entity
@Table(name = "client_interview_record")
public class ClientInterviewRecord {

    @Id
    @GeneratedValue
    private Long id;

    /**
     * 访谈地点
     */
    private String interviewLocation;

    /**
     * 访谈概要
     */
    private String interviewSummary;

    /**
     * 访谈详情
     */
    private String interviewDetail;

    /**
     * 访谈时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date interviewTime;

    private Date createTime;

    @ManyToOne
    @JoinColumn(nullable = false)
    private Client client;

    @ManyToOne
    @JoinColumn(nullable = false)
    private Principal principal;

    @Column(name = "is_disabled")
    private Boolean disabled;

    /**
     * 创建新访谈记录
     * @param client
     * @return
     */
    public ClientInterviewRecord create(Client client, Principal principal) {
        this.client = client;
        this.principal = principal;
        this.disabled = false;
        this.createTime = new Date();
        return this;
    }

    /**
     * 删除
     * @return
     */
    public ClientInterviewRecord delete() {
        this.disabled = true;
        return this;
    }

    /**
     * 获取格式化访谈时间
     * @return
     */
    public String getFormatedInterviewDetail() {
        return DateFormatUtils.format(this.interviewTime);
    }

    /**
     * 修改
     * @param clientInterviewRecord
     * @return
     */
    public ClientInterviewRecord edit(ClientInterviewRecord clientInterviewRecord) {
        this.interviewTime = clientInterviewRecord.getInterviewTime();
        this.interviewLocation = clientInterviewRecord.getInterviewLocation();
        this.interviewDetail = clientInterviewRecord.getInterviewDetail();
        this.interviewSummary = clientInterviewRecord.getInterviewSummary();
        return this;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getInterviewLocation() {
        return interviewLocation;
    }

    public void setInterviewLocation(String interviewLocation) {
        this.interviewLocation = interviewLocation;
    }

    public String getInterviewSummary() {
        return interviewSummary;
    }

    public void setInterviewSummary(String interviewSummary) {
        this.interviewSummary = interviewSummary;
    }

    public String getInterviewDetail() {
        return interviewDetail;
    }

    public void setInterviewDetail(String interviewDetail) {
        this.interviewDetail = interviewDetail;
    }

    public Date getInterviewTime() {
        return interviewTime;
    }

    public void setInterviewTime(Date interviewTime) {
        this.interviewTime = interviewTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    public Principal getPrincipal() {
        return principal;
    }

    public void setPrincipal(Principal principal) {
        this.principal = principal;
    }
}
